package com.first.nell.repay

import android.annotation.SuppressLint
import android.view.View
import androidx.lifecycle.ViewModel
import androidx.navigation.findNavController
import com.first.nell.R
import com.first.nell.base.BaseActivity
import com.first.nell.databinding.ActivityFirstNellRepayBinding
import com.first.nell.enums.PageTagEnum
import com.first.nell.me.MeRepayFragmentDirections
import com.first.nell.statement.StatementRepayFragmentDirections


/** 还款页 */
@SuppressLint("CustomSplashScreen")
class RepayActivity : BaseActivity() {

    private lateinit var mFirstNellActivityFirstNellBinding: ActivityFirstNellRepayBinding

    override fun onFirstNellBindingFirstNellViewFirstNellModel(): List<ViewModel>? {
        val list = mutableListOf<ViewModel>()
        return list
    }

    override fun onFirstNellBindingFirstNellViewFirstNellTag(): String {
        return PageTagEnum.repay.name.uppercase()
    }

    override fun onFirstNellBindingFirstNellContentFirstNellView(): View {
        mFirstNellActivityFirstNellBinding = ActivityFirstNellRepayBinding.inflate(layoutInflater)
        return mFirstNellActivityFirstNellBinding.root
    }

    override fun onFirstNellContentFirstNellViewFirstNellBinded() {
        try {
            mFirstNellActivityFirstNellBinding.bottomTabBarRepay.setFirstNellOnFirstNellActionFirstNellClickFirstNellListener {
                when (it) {
                    0 -> {
                        if (findNavController(R.id.navRepayFragment).currentDestination?.id == R.id.repay_me) {
                            findNavController(R.id.navRepayFragment)
                                .navigate(MeRepayFragmentDirections.toRepayHome())

                        } else if (findNavController(R.id.navRepayFragment).currentDestination?.id == R.id.repay_statement) {
                            findNavController(R.id.navRepayFragment)
                                .navigate(StatementRepayFragmentDirections.toRepayHome())
                        }
                    }
                    1 -> {
                        if (findNavController(R.id.navRepayFragment).currentDestination?.id == R.id.repay_home) {
                            findNavController(R.id.navRepayFragment)
                                .navigate(RepayFragmentDirections.toRepayStatement())

                        } else if (findNavController(R.id.navRepayFragment).currentDestination?.id == R.id.repay_me) {
                            findNavController(R.id.navRepayFragment)
                                .navigate(MeRepayFragmentDirections.toRepayStatement())
                        }
                    }
                    2 -> {
                        if (findNavController(R.id.navRepayFragment).currentDestination?.id == R.id.repay_home) {
                            findNavController(R.id.navRepayFragment)
                                .navigate(RepayFragmentDirections.toRepayMe())

                        } else if (findNavController(R.id.navRepayFragment).currentDestination?.id == R.id.repay_statement) {
                            findNavController(R.id.navRepayFragment)
                                .navigate(StatementRepayFragmentDirections.toRepayMe())
                        }
                    }
                    else -> {

                    }
                }
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

}